<?php

namespace XXXX\PlatformBundle\Util;

/**
 * prepare flush for curses expiry notification
 *
 * @author Ryszard Ratajczak <rratajczak@xxxx.com.pl>
 */
class CursesExpiryNotification
{
    /**
     * Router
     *
     * @var Symfony\Bundle\FrameworkBundle\Routing\Router
     */
    private $router;

    /**
     * Inject router
     *
     * @param Symfony\Bundle\FrameworkBundle\Routing\Router $router - router
     */
    public function __construct($router)
    {
        $this->router = $router;
    }

    /**
     * @param Collections $coursesCollections
     *
     * @return array - data for flash
     */
    public function prepareFlash($coursesCollections)
    {
        foreach ($coursesCollections as $course) {
            $expirationDate = $course->getExpirationDate();
            $list[] = $expirationDate->format('d') . '/' .
                      $expirationDate->format('m') . '/' .
                      $expirationDate->format('Y') . ' - ' .
                      $course->getName();
        }

        return array(
            'link' => $this->router->generate('course_edit', array('id' => $coursesCollections[0]->getId()), true),
            'listOfExpiredCourses' => $list,
            'messageBeforeListOfExpiredCourses' => 'homepage.message.before.list.of.expiring.courses',
            'messageStart' => 'homepage.click',
            'messageEnd' => 'homepage.to.change.course',
            'SSMessage' => 'homepage.please.do.not.remind.me.again'
        );
    }
}
